home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / DCLAP 4j / network / nsclilib / ni_msg.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-17  |  8.9 KB  |  290 lines  |  [TEXT/R*ch]

  1. /*
  2. * ===========================================================================
  3. *
  4. *                            PUBLIC DOMAIN NOTICE
  5. *               National Center for Biotechnology Information
  6. *
  7. *  This software/database is a "United States Government Work" under the
  8. *  terms of the United States Copyright Act.  It was written as part of
  9. *  the author's official duties as a United States Government employee and
  10. *  thus cannot be copyrighted.  This software/database is freely available
  11. *  to the public for use. The National Library of Medicine and the U.S.
  12. *  Government have not placed any restriction on its use or reproduction.
  13. *
  14. *  Although all reasonable efforts have been taken to ensure the accuracy
  15. *  and reliability of the software and data, the NLM and the U.S.
  16. *  Government do not and cannot warrant the performance or results that
  17. *  may be obtained by using this software or data. The NLM and the U.S.
  18. *  Government disclaim all warranties, express or implied, including
  19. *  warranties of performance, merchantability or fitness for any particular
  20. *  purpose.
  21. *
  22. *  Please cite the author in any work or product based on this material.
  23. *
  24. * ===========================================================================
  25. *
  26. * File Name:    ni_msg.h
  27. *
  28. * Author:       Beatty, Gish
  29. *
  30. * Version Creation Date:        1/1/92
  31. *
  32. * $Revision: 1.10 $
  33. *
  34. * File Description:
  35. *
  36. *
  37. * Modifications:
  38. * --------------------------------------------------------------------------
  39. * Date     Name        Description of modification
  40. * -------  ----------  -----------------------------------------------------
  41. * 5/12/92  Epstein     Converted tabs to spaces
  42. *
  43. * 04-21-93 Schuler     Changed declaration of NI_AsnNew(), NI_AsnWrite(), 
  44. *                      and NI_ASNIOError() to use LIBCALLBACK calling convention.
  45. *
  46. *
  47. * ==========================================================================
  48. */
  49.  
  50. #ifndef _NI_MSG_
  51. #define _NI_MSG_
  52.  
  53. #include <setjmp.h>
  54.  
  55. #include "ncbinet.h"
  56. #include "ni_net.h"
  57.  
  58. #include "ni_list.h"
  59.  
  60.  
  61. #ifdef WIN16
  62. #define Jumpbuf   CATCHBUF
  63. #define SetJump   Catch
  64. #define LongJump  Throw
  65. #else
  66. #define Jumpbuf   jmp_buf
  67. #define SetJump   setjmp
  68. #define LongJump  longjmp
  69. #endif
  70.  
  71. #define NI_BLOCK_TIMEOUT        60
  72. #define NI_BLOCKSIZE            4096 /* matches TCP_MAXSEG in many systems */
  73.  
  74. /* VARS */
  75.  
  76. extern Uint4    conid;          /* globally unique connection ID counter */
  77.  
  78.  
  79. /* TYPES */
  80.  
  81. #define MsgType enum msgtype
  82. MsgType {
  83.         NI_UNKNOWN = 0,
  84.         NI_ACK,
  85.         NI_NACK,
  86.         NI_LOGIN,
  87.         NI_SVC_LIST,
  88.         NI_SVC_REQUEST,
  89.         NI_SVC_RESPONSE,
  90.         NI_COMMAND,
  91.         NI_ACCT,
  92.         NI_CATALOG
  93. };
  94.  
  95. #define MsgCommand enum msgcommand
  96. MsgCommand {
  97.         NI_SEND_SVCLIST = 1,    /* send me a list of your services */
  98.         NI_SEND_CATALOG,        /* send me the catalog (dispatcher) */
  99.         NI_KILL,                /* kill yourself */
  100.         NI_POLL                 /* health check poll */
  101. };
  102.  
  103. typedef struct NIDispInfo {
  104.         Int4            serialno;       /* unique dispatcher serial # */
  105.         Boolean         isalternatelist;/* is this an alternate disp-list ? */
  106.         int             numdispatchers; /* number of dispachers in disp-list */
  107.         CharPtr PNTR    displist;       /* list of dispatchers */
  108. } NIDispInfo, PNTR NIDispInfoPtr;
  109.  
  110. typedef struct NIAck {
  111.         Uint4           seqno;
  112.         NIDispInfoPtr   dispinfo;
  113. } NIAck, PNTR NIAckPtr;
  114.  
  115. typedef struct NINack {
  116.         Uint4           seqno;
  117.         NI_Error        code;
  118.         CharPtr         reason;
  119.         NIDispInfoPtr   dispinfo;
  120. } NINack, PNTR NINackPtr;
  121.  
  122. typedef struct NILogin {
  123.         Uint4           seqno;
  124.         NI_UidPtr       uid;            /* ID structure */
  125.         CharPtr         password;       /* must be encrypted */
  126.         Int4            dispserialno;   /* unique dispatcher serial # */
  127. } NILogin, PNTR NILoginPtr;
  128.  
  129. typedef struct NISvcList {
  130.         Uint4           seqno;
  131.         NIToolsetPtr    toolset;
  132. } NISvcList, PNTR NISvcListPtr;
  133.  
  134. typedef struct NISvcReq {
  135.         Uint4           seqno;
  136.         Uint4           conid;          /* for client accounting */
  137.         NI_UidPtr       uid;
  138.         ReqPtr          request;
  139.         Uint4           platform;       /* client's platform */
  140.         CharPtr         applId;         /* application identifier */
  141. } NISvcReq, PNTR NISvcReqPtr;
  142.  
  143. typedef struct NISvcResp {
  144.         Uint4           seqno;
  145.         ReqPtr          request;
  146. } NISvcResp, PNTR NISvcRespPtr;
  147.  
  148. typedef struct NICmd {
  149.         Uint4           seqno;
  150.         MsgCommand      code;
  151. } NICmd, PNTR NICmdPtr;
  152.  
  153. typedef struct NIAcct {
  154.         Uint4           seqno;
  155.         Uint4           conid;
  156.         CharPtr         jobname;
  157.         Uint4           usertime;
  158.         Uint4           systemtime;
  159. } NIAcct, PNTR NIAcctPtr;
  160.  
  161. typedef union NIMSun {
  162.         NIAckPtr        ack;
  163.         NINackPtr       nack;
  164.         NILoginPtr      login;
  165.         NISvcListPtr    svclist;
  166.         NISvcReqPtr     svcreq;
  167.         NISvcRespPtr    svcresp;
  168.         NICmdPtr        command;
  169.         NIAcctPtr       acct;
  170.         NICatalogPtr    catalog;
  171. } NIMSun, PNTR NIMSunPtr;
  172.  
  173. typedef struct NIMessage {
  174.         MsgType         type;
  175.         Uint4           conid;          /* for ACKing */
  176.         NIMSun          msun;           /* message structure union */
  177. } NIMessage, PNTR NIMsgPtr;
  178.  
  179.  
  180. /* FUNCTION PROTOTYPES */
  181.  
  182. extern NIMsgPtr         MsgRead PROTO((MHandPtr handle, Boolean unblocked));
  183.  
  184. extern Int2             MsgWrite PROTO((MHandPtr handle, NIMsgPtr mp));
  185.  
  186. extern NIMsgPtr         MsgBuild PROTO((MsgType type, Uint4 conn, VoidPtr stp));
  187.  
  188. extern Int2             MsgDestroy PROTO((NIMsgPtr mp));
  189.  
  190. extern MHandPtr         MsgMakeHandle PROTO((Boolean createSocket));
  191.  
  192. extern Int2             MsgDestroyHandle PROTO((MHandPtr hp));
  193.  
  194. extern void             MsgSetLJError PROTO((MHandPtr mh));
  195.  
  196. extern void             MsgSetReadTimeout PROTO((MHandPtr mh, int t));
  197.  
  198. extern void             MsgSetWriteTimeout PROTO((MHandPtr mh, int t));
  199.  
  200. extern void             MsgSetFilters PROTO((MHandPtr mh, VoidPtr ex_proc, NI_WriteFilt wfilt, NI_ReadFilt rfilt, Boolean wfilt_pass, Boolean rfilt_pass));
  201.  
  202. extern void             MsgSetTimeoutHooks PROTO((MHandPtr mh, NI_TimeoutHook rhook, NI_TimeoutHook whook));
  203.  
  204. extern Int2 LIBCALLBACK NI_AsnRead PROTO((Pointer p, CharPtr buf, Uint2 len));
  205.  
  206. extern Int2 LIBCALLBACK NI_AsnWrite PROTO((Pointer p, CharPtr buf, Uint2 len));
  207.  
  208. extern void LIBCALLBACK NI_ASNIOError PROTO((Int2 level, CharPtr str));
  209.  
  210. extern int              NI_poll_select PROTO((int width, fd_set PNTR rfds, fd_set PNTR wfds, fd_set PNTR xfds, struct timeval PNTR timeout));
  211. extern int              NI_SetBlocking PROTO((int sock));
  212. extern int              NI_SetNonBlocking PROTO((int sock));
  213.  
  214.  
  215. /* Message Type Functions */
  216.  
  217. extern NIAckPtr         NI_MakeMsgAck PROTO((void));
  218.  
  219. extern Int2             NI_DestroyMsgAck PROTO((NIAckPtr));
  220.  
  221. extern NINackPtr        NI_MakeMsgNack PROTO((void));
  222.  
  223. extern Int2             NI_DestroyMsgNack PROTO((NINackPtr));
  224.  
  225. extern NILoginPtr       NI_MakeMsgLogin PROTO((void));
  226.  
  227. extern Int2             NI_DestroyMsgLogin PROTO((NILoginPtr));
  228.  
  229. extern NISvcListPtr     NI_MakeMsgSvclist PROTO((void));
  230.  
  231. extern Int2             NI_DestroyMsgSvclist PROTO((NISvcListPtr));
  232.  
  233. extern NISvcReqPtr      NI_MakeMsgSvcreq PROTO((void));
  234.  
  235. extern Int2             NI_DestroyMsgSvcreq PROTO((NISvcReqPtr));
  236.  
  237. extern NISvcRespPtr     NI_MakeMsgSvcresp PROTO((void));
  238.  
  239. extern Int2             NI_DestroyMsgSvcresp PROTO((NISvcRespPtr));
  240.  
  241. extern NICmdPtr         NI_MakeMsgCmd PROTO((void));
  242.  
  243. extern Int2             NI_DestroyMsgCmd PROTO((NICmdPtr));
  244.  
  245. extern NIAcctPtr        NI_MakeMsgAcct PROTO((void));
  246.  
  247. extern Int2             NI_DestroyMsgAcct PROTO((NIAcctPtr));
  248.  
  249. extern NISvcPtr         NI_MakeService PROTO((void));
  250.  
  251. extern Int2             NI_DestroyService PROTO((NISvcPtr));
  252.  
  253. extern NIResPtr         NI_MakeResource PROTO((void));
  254.  
  255. extern Int2             NI_DestroyResource PROTO((NIResPtr));
  256.  
  257. extern NIRegionPtr      NI_MakeRegion PROTO((void));
  258.  
  259. extern Int2             NI_DestroyRegion PROTO((NIRegionPtr));
  260.  
  261. extern ReqPtr           NI_MakeRequest PROTO((void));
  262.  
  263. extern Int2             NI_DestroyRequest PROTO((ReqPtr));
  264.  
  265. extern NICatalogPtr     NI_MakeMsgCatalog PROTO((void));
  266.  
  267. extern Int2             NI_DestroyMsgCatalog PROTO((NICatalogPtr));
  268.  
  269. extern NI_UidPtr        NI_MakeUid PROTO((void));
  270.  
  271. extern Int2             NI_DestroyUid PROTO((NI_UidPtr));
  272.  
  273. extern NIDispInfoPtr    NI_MakeDispInfo PROTO((void));
  274.  
  275. extern Int2             NI_DestroyDispInfo PROTO((NIDispInfoPtr));
  276.  
  277. extern int              NI_ReadDispInfo PROTO((AsnIoPtr extaip, AsnTypePtr extatp, NIDispInfoPtr dip));
  278. extern void             NI_WriteDispInfo PROTO((AsnIoPtr extaip, AsnTypePtr extatp, NIDispInfoPtr dip));
  279.  
  280. extern Int2             NI_DestroyDispInfo PROTO((NIDispInfoPtr));
  281.  
  282. extern NIToolsetPtr     NI_MakeToolset PROTO((void));
  283.  
  284. extern Int2             NI_DestroyToolset PROTO((NIToolsetPtr tsp));
  285.  
  286. extern NIToolsetPtr     NI_GetCatToolset PROTO((NIToolsetPtr tsp));
  287.  
  288.  
  289. #endif
  290.